package basic;

public class ArrayGetMaxDemo {
    public static void main(String[] args) {
        int[] arr = {20,30,15,70,92,11};
        int max = arr[0];
        //遍历数组
        for (int i = 0; i < arr.length; i++){
            //若元素arr[i]的值大于max，则讲元素arr[i]的值赋值给max
            //直到遍历结束获取数组的元素中的最大值
            if (arr[i] > max){
                max = arr[i];
            }
        }
        System.out.println("最大值为：" + max);
    }
}
